// const MongoClient = require('mongodb').MongoClient;
const {MongoClient, ObjectID} = require('mongodb');


MongoClient.connect('mongodb://localhost:27017/TodaApp', (err, db) => {
    if (err) {
        return console.log('Unable to connect the mongodb server')
    }

    console.log('Connected to MongDB server');

    // deleteMany
    // db.db('TodoApp').collection('Todos').deleteMany({text: 'Eat lunch'}).then((result) => {
    //     console.log(result);
    // })


    // deleteOne
    // db.db('TodoApp').collection('Todos').deleteOne({text: 'Eat lunch'}).then((res) => {
    //     console.log(res);
    // });




    // findeOneAndDelete
    // db.db('TodoApp').collection('Todos').findOneAndDelete({completed: false}).then((res) => {
    //     console.log(res);
    // })

    // db.db('TodoApp').collection('Users').deleteMany({name: 'Tony'}).then((res) => {
    //     console.log(res);
    // })

    db.db('TodoApp').collection('Users').findOneAndDelete({_id: new ObjectID('5a38947bb70bc8c56f084911')}).then((res) => {
        console.log(JSON.stringify(res, undefined, 2));
    })







    // db.close();

})

